<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <div id="app">
        <h3>我是父亲</h3>
        <input type="text" v-model="letter">
        <hr>
        <son :message="msg"></son>
        <daughter :letter="letter"></daughter>
    </div>

    <template id="son">
        <div>
            <h3>我是儿子</h3>
            <p>{{message}}</p>
        </div>
    </template>

    <template id="daughter">
        <div>
            <h3>我是女儿</h3>
            <p>{{letter}}</p>
        </div>
    </template>

    <script src="../lib/Vue/vue.js"></script>
    <script>
        // 1.需要在子组件的标签上绑定一个属性，父组件传递给子组件的值通过属性绑定的方式传递过去
		// 2.在子组件中需要定义props，来接受来自父组件的值（传递过来的属性）
        
        var son = {
            template: '#son',
            props: ['message']
        }

        var daughter = {
            template: '#daughter',
            props: {
                letter: {
                    type: String,
                    required: true,
                    default: '魏传消息'
                }
            },
            props: ['letter']
        }

        var vm =new Vue({
            el: '#app',
            data: {
                msg: '儿子，这是爸爸给你的信',
                letter: ''
            },
            components: {
                son,
                daughter
            }
        })
    </script>
</body>
</html>